package com.wonderplay.warlord;

import com.wonderplay.warlord.engine.WarLordGameEngine;
import com.wonderplay.warlord.module.combat.MainMatrix;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class WarLord extends Activity {
	/** Called when the activity is first created. */
	// @Override
	// public void onCreate(Bundle savedInstanceState) {
	// super.onCreate(savedInstanceState);
	// setContentView(new GameCanvas(this));
	// }

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		setContentView(new MyView(this));
		
		WarLordGameEngine engine = new WarLordGameEngine(this);
		setContentView(engine.getGameView());
	}

	class MyView extends SurfaceView implements SurfaceHolder.Callback {

		private SurfaceHolder mHolder;
		private Canvas canvas;

		public MyView(Context context) {
			super(context);
			mHolder = getHolder();
			mHolder.addCallback(this);
		}

		@Override
		public void surfaceChanged(SurfaceHolder holder, int format, int width,
				int height) {

		}

		@Override
		public void surfaceCreated(SurfaceHolder holder) {
			canvas = mHolder.lockCanvas();
			Paint mPaint = new Paint();
			mPaint.setColor(Color.BLUE);
			canvas.drawRect(100, 200, 200, 300, mPaint);

//			canvas.save();
			canvas.rotate(45);
			mPaint.setColor(Color.RED);
			canvas.drawRect(150, 10, 200, 60, mPaint);
//			canvas.restore();
			mHolder.unlockCanvasAndPost(canvas);
		}

		@Override
		public void surfaceDestroyed(SurfaceHolder holder) {
			// TODO Auto-generated method stub

		}

	}

}